package edu.scau.divineplace.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import edu.scau.divineplace.entity.enums.LikeTargetTypeEnum;
import edu.scau.divineplace.entity.query.PageQuery;
import edu.scau.divineplace.entity.vo.JournalVO;
import edu.scau.divineplace.mapper.JournalServiceMapper;
import edu.scau.divineplace.util.PageQueryUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: x1aolone
 * @Date: 2020/12/11 15:48
 */
@Service
public class JouanlService {

    @Autowired
    private ImportMapperService importMapperService;

    @Autowired
    private JournalServiceMapper journalServiceMapper;

    /**
     * 通过用户id获取日志列表
     * @param userId
     * @return
     */
    public List<JournalVO> list(Long userId, PageQuery pageQuery){
        PageQueryUtil.fillAllIfAbsent(pageQuery);
        Page<JournalVO> journalPage = new Page<>(pageQuery.getCurrentPage(), pageQuery.getPageSize());
        List<JournalVO> VOS = journalServiceMapper
                .selectJournalByUserId(journalPage, userId, LikeTargetTypeEnum.JOURNAL.getType())
                .getRecords();
        return VOS;
    }

}
